package com.common;

import org.apache.shiro.authc.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ShiroExceptionUtil extends Exception {

    private static ShiroExceptionUtil me;

    private Logger logger = LoggerFactory.getLogger(ShiroExceptionUtil.class);

    public static ShiroExceptionUtil getShiroExceptionUtil(){
        if(me==null){
            me=new ShiroExceptionUtil();
        }
        return me;
    }

    public void savereason(Exception e) {
        if (e instanceof DisabledAccountException) {
            logger.error(ConstUtil.DisabledAccount);
        } else if (e instanceof LockedAccountException) {
            logger.error(ConstUtil.LockedAccount);
        } else if (e instanceof UnknownAccountException) {
            logger.error(ConstUtil.UnknownAccount);
        } else if (e instanceof ExcessiveAttemptsException) {
            logger.error(ConstUtil.ExcessiveAttempts);
        } else if (e instanceof IncorrectCredentialsException) {
            logger.error((ConstUtil.IncorrectCredentials));
        } else if (e instanceof ExpiredCredentialsException) {
            logger.error(ConstUtil.ExpiredCredentials);
        }else{
            logger.error(ConstUtil.Exception+":"+e.getMessage());
        }
    }

    private ShiroExceptionUtil(){}
}
